<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2020/11/23
  Time: 下午 4:41
  To change this template use File | Settings | File Templates.
--%>

<%@ page language="java" import="java.util.*,dao.*,dao.impl.*,entity.*" pageEncoding="utf-8"%>
<%
    BoardDao boardDao = new BoardDaoImpl();
    TopicDao topicDao = new TopicDaoImpl();
    UserDao userDao = new UserDaoImpl();
    Map mapBoard = boardDao.findBoard();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>首页</title>
    <style type="text/css">
        #apDiv1 {
            position: absolute;
            left: 1px;
            top: 1px;
            width: 800px;
            height: 50px;
            z-index: 1;
        }
        #apDiv2 {
            position: absolute;
            left: 1px;
            top: 51px;
            width: 800px;
            height: 25px;
            z-index: 2;
            font-size: 12px;
            color: #004c7d;
            background-color: #e0f0f9;
        }
        #apDiv3 {
            position: absolute;
            left: 1px;
            top: 76px;
            width: 800px;
            height: 500px;
            z-index: 3;
        }
        #apDiv1 {
            font-size: 24px;
        }
        #apDiv1 {
            text-align: center;
        }
        #apDiv1 {
            color: #F00;
        }



    </style>
</head>

<body>
<!--注释-->
<div id="apDiv1">
    <p>校园BBS系统</p>
</div>
<div id="apDiv2">您尚未<a href="login.jsp" target="_blank">登录</a> |
    <a href="reg.jsp" target="_blank">注册</a>
</div>
<div id="apDiv3">
    <table width="100%" border="1" height="503" cellspacing="0" cellpadding="0">
        <tr>
            <td colspan="2" align="left" valign="middle"><span class="STYLE4">论坛</span></td>
            <td width="5%" class="STYLE4">主题</td>
            <td width="45%" class="STYLE4">之后发表</td>
        </tr>
        <!-- 主板块 -->
        <%
            List listMainBoard = (List)mapBoard.get(new Integer(0));
            for(int i = 0;i<listMainBoard.size();i++) {
                Board mainBoard = ((Board) listMainBoard.get(i));//循环获得主版块
        %>
        <tr>
            <!-- <td colspan="4" class="STYLE4">NET方向:</td> -->
            <td colspan="4" class="STYLE4"><%= mainBoard.getBoardName() %></td>
        </tr>
        <!--子版块  -->
        <%
            List listSonBoard = (List)mapBoard.get(new Integer(mainBoard.getBoardId()));
            for(int j = 0;j<listSonBoard.size();j++){
                Board sonBoard = (Board)listSonBoard.get(j);  //循环取得子版块
                Topic topic = new Topic();					  //最后发表的主题
                User user = new User();						  //最后发表的主题的作者
                int boardId = sonBoard.getBoardId();
                List listTopic = topicDao.findListTopic(1, boardId);
                //取得该版块主题列表
                if(listTopic!=null && listTopic.size()>0){
                    topic = (Topic)listTopic.get(0);    		  //取得最后发表的帖子
                    user = userDao.findUser(topic.getUid());
                }
        %>
        <tr>
            <td width = "5%">&nbsp;</td>
            <th align = "left">
                <img src = "image/board.gif">
                <a href = "list.jsp"><%=sonBoard.getBoardName() %></a>
            </th>
            <td align = "center"><%=topicDao.findCountTopic(boardId) %></td>
            <th>
     		<span>
     			<a href="detail.jsp"><%=topic.getTitle() %></a>
     		</span>
                <br/>
                <span><%=user.getUName() %></span>
                <span class="gray">[<%=topic.getPublishTime() %>]</span>
            </th>
        </tr>

        <%
                }
            }
        %>
    </table>
</div>
</body>
</html>
